package fr.umlv.ig.adapter;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import fr.umlv.ig.model.Line;
import fr.umlv.ig.model.Station;


/**
 * Tool with static methods JTable which used a {@link StationTableModel}
 * @author jenseric
 *
 */
public class StationTableRenderer {

	
	
	@SuppressWarnings("serial")
	public static DefaultTableCellRenderer METROTABLECELLRENDERER = new DefaultTableCellRenderer() {
		@Override
		public Component getTableCellRendererComponent(JTable table,
				Object value, boolean isSelected, boolean hasFocus,
				int row, int column) {
			if(value instanceof Line) {
				return super.getTableCellRendererComponent(table, ((Line) value).getName() , isSelected, hasFocus, row, column);
			}
			if(value instanceof Station) {		
				return super.getTableCellRendererComponent(table, ((Station) value).getName() , isSelected, hasFocus, row, column);
			}
			
			return super.getTableCellRendererComponent(table, null, isSelected, hasFocus,
					row, column);
		}
	};
	
}
